
"=============================================================================== 
"     __  ____   ___   ___     _____ __  __ ____   ____                         
"    |  \/  \ \ / /| \ | \ \   / /_ _|  \/  |  _ \ / ___|                       
"    | |\/| |\ V / |  \| |\ \ / / | || |\/| | |_) | |                           
"    | |  | | | |  | |\  | \ V /  | || |  | |  _ <| |___                        
"    |_|  |_| |_|  |_| \_|  \_/  |___|_|  |_|_| \_\\____|                       
"                                                                               
"    明天属于熬过今天的人！
"                                                                               
"    美妙人生的关键在于你能迷上什么东西!                                             
"                                                                               
"    人之所以不幸，是因为他不知道自己是幸福的，仅此而已。                              
"                                                                               
"===============================================================================
" echom "提示：This is plugins.vim"

"==============================================================================
"" 这个档案的双引号 (") 是批注


"===============================================================================
" 插件配置
"===============================================================================

" -----------------------------------------------------------------------------
" 插件管理工具 vim-plug 
	" > 参考资料
		" + [详谈Vim的配置层次结构与插件加载方式（一）](https://blog.csdn.net/qq_27825451/article/details/100518128)
		" + [vim8原生内置(naive)插件安装（二）](https://blog.csdn.net/qq_27825451/article/details/100557133)
		"+ [VIM 配置](https://www.jianshu.com/p/9536ec0d59a3) 

	" 手动安装
	"   curl -fLo ~/vimfiles/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

	" 自动安装

		let g:isInstallPlug = 0
		if(isWindows)
			let g:myUserPath = '~/AppData/Local/nvim/'
			" let g:myPlugPath = '~/AppData/Local/nvim/plugins'
			let g:myPlugPath = '~/.vim/plugins'
			let g:myPlugFile = '~/AppData/Local/nvim/autoload/plug.vim'
		else
			let g:myUserPath = '~/.config/nvim/'
			let g:myPlugPath = '~/.config/nvim/plugins'
			let g:myPlugFile = '~/.config/nvim/autoload/plug.vim'
		endif
		" echom "提示：$Vim        =".$VIM
		" echom "提示：$VIMRUNTIME =".$VIMRUNTIME
		" echom "提示：$HOME       =".$HOME
		
		function DownInstallPlug(PlugPathValue)
			echom "提示：进入DownInstallPlug()函数"
			echom "提示：PlugPathValue值为".a:PlugPathValue
			execute "[Debug print] silent !curl -flo ".a:PlugPathValue." --create-dirs  https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim"
			execute "!curl -flo ".a:PlugPathValue." --create-dirs  https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim"
			" silent !curl -flo ~/.nvim/autoload/plug.vim --create-dirs 
			"                        \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

		endfunction
	
		" echom "提示: myUserPath =".myUserPath
		" echom "提示: myPlugPath =".myPlugPath
		" echom "提示: myPlugFile =".myPlugFile
		
		if(!empty(glob(myPlugFile)))
			" echom "提示:".myPlugFile."已经存在。"
			let g:isInstallPlug = 1
		else
			" echom "提示：开始执行下载安装Plug插件"
			"execute :call DownInstallPlug(myPlugFile)
			call DownInstallPlug(myPlugFile) 
			" echom "提示：已经执行完下载plug.vim任务"
		endif
	" 使用
		" :PlugInstall    " 安装
		" :PlugClean      " 清除

	" 配置
		
		if(isInstallPlug)
			if((!empty(glob(myPlugPath)))) 
				" echom "提示:已有插件目录,应该不是第一次打开"
			else
				" 第一次打开且没装插件
				" echom "提示:进入时自动安装插件"
				" autocmd vimenter * PlugInstall 
				autocmd vimenter * new | PlugInstall --sync
			endif
		endif
		
		if(empty(glob(myPlugFile)))
			echom "提示:Plug插件文件没下载完成，并存于对应目录，不加载之后配置。"
			finish   " 没有安装则之后的配置不用再加载
			" 已经安装Plug插件才加载其配置（此处防止没安装Plug时会提示无plug#begin函数的错误提示）
		endif
		
		" if(isInstallPlug)
			call  plug#begin(myPlugPath)

				Plug 'liuchengxu/vim-which-key'                 " 显示按键导航
				Plug 'vim-ctrlspace/vim-ctrlspace'              " 
				Plug 'mhinz/vim-startify'                       " 开始引导页插件

				Plug 'airblade/vim-rooter'                      " 自动切换到项目根目录
				Plug 'francoiscabrol/ranger.vim'                " 终端文件管理器ranger
				Plug 'ptzz/lf.vim'                              " 终端文件管理器 LF
				Plug 'voldikss/vim-floaterm'                    " 悬浮窗口插件
				
				Plug 'mhinz/vim-signify'                        " git和svn版本变化侧边栏显示插件
				Plug 'iberianpig/tig-explorer.vim'              " git客户端tig

				Plug 'voldikss/vim-translator'                  " 翻译插件
				if(isNeovim)
					Plug 'rbgrouleff/bclose.vim'                " ranger.vim nvim要求依赖 关闭buf

				endif

				Plug 'junegunn/fzf',
				Plug 'junegunn/fzf.vim',                        " 模糊搜索

				Plug 'mbbill/undotree'                          " 撤销更改/撤销树插件
				
				Plug 'preservim/nerdcommenter'                  " 代码注释插件
				Plug 'ervandew/supertab'                        " 键入Tab键时具有上下文提示及补全功能

				Plug 'tpope/vim-surround'                       " 快速环绕插入符号
				Plug 'gcmt/wildfire.vim'                        " 快速选中文本对象（搭配vim-surround使用更搭哦）

				Plug 'christoomey/vim-system-copy'              " 系统剪贴板

				Plug 'dhruvasagar/vim-table-mode',{ 'on': 'TableModeToggle','for':'markdown'}  " markdown自动表格创建与格式化
				if(has('python3')) 
					" 需要python3特性执行的插件

					" 片段补全插件
					Plug 'SirVer/ultisnips'                     " 代码片段补全引擎插件（代码片段管理）
					Plug 'honza/vim-snippets'                   " 代码补全模板
				endif

				Plug 'neoclide/coc.nvim',{'do': {-> coc#util#install()}}     " 新一代补全插件

				if(isLinux || isMac)
					Plug 'christoomey/vim-tmux-navigator'       " vim + tmux窗格平滑切换插件
				endif
				if(isLinux)
					" Plug 'vim-scripts/fcitx.vim'              " fcitx输入法在不同模式下自动切换
					Plug '520Matches/fcitx5.vim'                " fcitx5输入法在不同模式下自动切换
				endif

				if(has('lua') && isNeovim)
					Plug 'akinsho/nvim-bufferline.lua'          " buffer显示插件
				else
					" Plug 'bling/vim-bufferline'                 " buffer显示插件
					" Plug 'fholgado/minibufexpl.vim'
					" Plug 'mengelbrecht/lightline-bufferline'
					" Plug 'vim-airline/vim-airline'              " 状态栏美化插件 (neovim也可以用)
					" Plug 'vim-airline/vim-airline-themes'
				endif
				
				Plug 'PsychoLlama/teleport.vim'                 " 快速跳转插件(可配合 z.lua autojump使用)

				Plug 'tomasr/molokai'                           " molokai 主题
				" Plug 'yuttie/inkstained-vim'                    " inkstained 主题
			call plug#end()
		" endif

" -----------------------------------------------------------------------------
" 插件配置
" 拆分配置文件
if(isWindows)
	source ~/AppData/Local/nvim/plugins-vim-which-key.vim
	" source ~/AppData/Local/nvim/plugins-ranger.vim
	source ~/AppData/Local/nvim/plugins-undotree.vim
	" source ~/AppData/Local/nvim/plugins-airline.vim
else
	source ~/.config/nvim/plugins-vim-which-key.vim
	" source ~/.config/nvim/plugins-ranger.vim
	source ~/.config/nvim/plugins-undotree.vim
	" source ~/.config/nvim/plugins-airline.vim
endif



